#ifndef _Init_h
#define _Init_h

#include "zf_common_headfile.h"

//  TTTTTIME
#define TIM7_priority       0
#define GPS_priority        1 // 
#define WIT_priority        2
#define VOFA_priority       7 // 7
#define TIM6_priority       4
#define TIM5_priority       3
#define SBUS_priority       6
// SSSSSBUS 
#define SBUS_UART           UART_5
#define SBUS_UART_TX        UART5_TX_A4
#define SBUS_UART_RX        UART5_RX_A5
#define SBUS_UART_PRIORITY  UART5_IRQn 
// KKKKKEY AND LED
#define LED1				E3								// 
#define KEY0				D0								// 
#define KEY1				D1								// 
#define KEY2				D2								//  
#define KEY3				D3								// 

#define SWITCH_1            D14								// 
#define SWITCH_2            D15								// 
// BBBBBUZZER
#define BUZZER_PIN			D12								 
// BBBBBRUSHLESS MOTOR
#define MAX_DUTY            95                              // 最大占空比输出限制
#define V_GRID              10
#define MOTOR_PWM_CH        TIM2_PWM_CH3_A2                 // PWM输出端口
#define MOTOR_DIR_CH        A3                              // 电机方向输出端口
// HHHHHALL ENCODER
#define ENCODER_TIM         TIM3_ENCOEDER                   // 编码器定时器
#define ENCODER_PLUS        TIM3_ENCOEDER_CH1_B4            // 编码器计数端口
#define ENCODER_DIR         TIM3_ENCOEDER_CH2_B5            // 编码器方向采值端口
// GGGGGPS
#define GPS_TAU1201_UART    (UART_3)
#define GPS_TAU1201_RX      (UART3_TX_B10)                                      // GPS RX引脚连接到单片机此
#define GPS_TAU1201_TX      (UART3_RX_B11)                                      // GPS TX串口引脚
#define GPS_UART_PRIORITY   (UART3_IRQn)
// WWWWWWIT_gyro
#define GORY_UART           UART_6
#define GORY_UART_TX        UART6_TX_B0
#define GORY_UART_RX        UART6_RX_B1
#define GORY_UART_PRIORITY  UART6_IRQn 
// SSSSSERVO
#define SERVO_PWM           TIM2_PWM_CH1_A15             
#define SERVO_FREQ          50                 // operating frequency of steering gear 50-300
#define Servo_CASCADE       1                   // Servo_CASCADE PID enanble macro definton
#define Servo_SD9           1                   // reverse control of steering gear --By modifying the location PID 
#define SERVO_MEDIAN        1130       //1800 & 0       1390 & 1
#define SERVO_UPPER         SERVO_MEDIAN+200    // left
#define SERVO_LOWER         SERVO_MEDIAN-200
#define SERVO_UPPER_m       SERVO_MEDIAN+200 //SERVO_MEDIAN+30 // left
#define SERVO_LOWER_m       SERVO_MEDIAN-200 //SERVO_MEDIAN-30
#define SERVO_GRID          15
// VVVVVOFA 
#define VOFA_UART           UART_4
#define VOFA_UART_TX        UART4_TX_C10
#define VOFA_UART_RX        UART4_RX_C11
#define VOFA_UART_PRIORITY  UART4_IRQn 
// MENU
#define PID_P_GRID          0.05f
#define PID_D_GRID          0.05f
// GPS inf
#define Point_Spacing       15
//////////////////////// Temporary variable ////////////////////////
extern char Go, Flag_auto_check, flag_updata;
extern char STATE_auto_get;
extern float time_i, time_j, time_k;
// GPS filtering, temporary  variable
extern float lat,lon,dir;
// Take the nearest GPS point, temporary variable
extern int16 temporally_i;
extern float mini_dis;
//////////////////////// variable ////////////////////////
extern float V_duty;
extern float Esp_ang;
void All_Init(void);
void get_flash(void);//need to be modified
#endif
